
local currentId = KEYS[1];
local currentSetKey = 'addresslist:id:' .. currentId;
local currentUser = redis.call('SMEMBERS', currentSetKey)

local results = {}
for _, id in ipairs(currentUser) do
    -- 获取每个关联用户ID对应的set集合
    local relatedUserSetKey = 'addresslist:id:' .. id
    -- 计算传入的用户集合与关联用户集合的差集
    local diff = redis.call('SDIFF', relatedUserSetKey, currentSetKey)
    -- 将差集结果存入表中
    for _,diffMember in ipairs(diff) do
        if diffMember ~= currentId then
            table.insert(results, diffMember)
        end
    end
end
return results